﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display {
    import flash.events.*;
    import Engine.Managers.*;
    import flash.display.*;
    import Transactions.*;
    import Classes.util.*;

    public class GiftNotify extends SWFDialog {

        private var m_window:MovieClip;
        private var m_numGifts:int;
        private var m_accept:GenericButton;
        private var m_reject:GenericButton;

        public function GiftNotify(_arg1:int, _arg2:Boolean=true){
            m_dialogAsset = "assets/dialogs/FV_GiftNotify.swf";
            this.m_numGifts = _arg1;
            super(_arg2);
        }
        override protected function onLoadComplete():void{
            this.m_window = (m_loader.content as MovieClip);
            this.m_window.giftNotify_mc.giftNotify_tf.text = ZLoc.t("Dialogs", "GiftsWaiting", {num:this.m_numGifts});
            this.m_window.giftNotify_mc.lookAtGifts_tf.text = ZLoc.t("Dialogs", "SellGifts");
            var _local1:int = Global.gameSettings.getInt("maxGiftLimit");
            if (this.m_numGifts >= _local1){
                this.m_window.giftNotify_mc.maxGifts_tf.text = ZLoc.t("Dialogs", "MaxGifts", {max:_local1});
                this.m_window.giftNotify_mc.maxGifts_tf.visible = true;
            } else {
                this.m_window.giftNotify_mc.maxGifts_tf.visible = false;
            };
            this.m_accept = new GenericButton(this.m_window.giftNotify_mc.accept_bt, this.onAcceptClick);
            this.m_accept.text = ZLoc.t("Dialogs", "Accept");
            this.m_reject = new GenericButton(this.m_window.giftNotify_mc.cancel_bt, this.onCloseClick);
            this.m_reject.text = ZLoc.t("Dialogs", "Cancel");
            StatsManager.count("flash_giftNotify", "automatic", "viewInitial");
            addChild(this.m_window);
            StatsManager.milestone("gifts_waiting_md");
        }
        private function onAcceptClick(_arg1:MouseEvent):void{
            this.onCloseClick(_arg1);
            UI.displayGiftDialog();
            StatsManager.count("flash_giftNotify", "automatic", "accept");
            StatsManager.milestone("gift_box_md");
        }
        private function onCloseClick(_arg1:MouseEvent):void{
            _arg1.stopPropagation();
            StatsManager.count("flash_giftNotify", "automatic", "close");
            Global.player.options.noGiftNotify = GlobalEngine.getTimer();
            GameTransactionManager.addTransaction(new TSaveOptions(Global.player.options));
            close();
        }

    }
}//package Display 
